package com.vogue.flowmeter.api;

import com.vogue.flowmeter.api.entity.ApiAuthorizeEntity;
import com.vogue.flowmeter.api.entity.ApiRecordEntity;
import com.vogue.flowmeter.api.entity.ApiUpdateApkEntity;
import com.vogue.flowmeter.api.entity.ApiUpdateHexEntity;
import com.vogue.flowmeter.api.entity.BaseResponse;

import java.util.HashMap;

import io.reactivex.Observable;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Url;

/**
 * 接口管理
 */
public interface BleApiService {

    //String APP_DEFAULT_DOMAIN = "http://192.168.1.8:8080";
    String APP_DEFAULT_DOMAIN = "https://ble.34qu.cn";

    /**
     * 设备注册
     * @param authorize
     * @return
     */
    @POST("/app/register")
    @Headers({ "Content-Type: application/json;charset=UTF-8"})
    Observable<ResponseBody> register(@Body ApiAuthorizeEntity authorize);
    /**
     * 设备授权
     * @param authorize  BaseResponse<ApiAuthorizeEntity>
     * @return
     */
    @POST("/app/authorization")
    @Headers({ "Content-Type: application/json;charset=UTF-8"})
    Observable<ResponseBody> getAuthorization(@Body ApiAuthorizeEntity authorize);
    /**
     * 蓝牙（HEX）更新信息
     * @param updateHex
     * @return
     */
    @POST("/app/getUpdateHex")
    @Headers({ "Content-Type: application/json;charset=UTF-8"})
    Observable<ResponseBody> getUpdateHex(@Body ApiUpdateHexEntity updateHex);

    /**
     * APP更新信息
     * @param updateApk
     * @return
     */
    @POST("/app/getUpdateApk")
    @Headers({ "Content-Type: application/json;charset=UTF-8"})
    Observable<ResponseBody> getUpdateApk(@Body ApiUpdateApkEntity updateApk);
    /**
     * 操作记录列表
     * @param params
     * @return
     */
    @POST("/app/record/list")
    @Headers({ "Content-Type: application/json;charset=UTF-8"})
    Observable<ResponseBody> getRecords(@Body HashMap<String, Object> params);
    /**
     * 设备注册
     * @param apiRecord
     * @return
     */
    @POST("/app/record/save")
    @Headers({ "Content-Type: application/json;charset=UTF-8"})
    Observable<BaseResponse> saveRecord(@Body ApiRecordEntity apiRecord);
    /**
     * 下载文件
     * 如果下载大文件的一定要加上  @Streaming  注解
     * @param fileUrl 文件的路径
     * @return 请求call
     */
    @GET
    Call<ResponseBody> download(@Url String fileUrl);
}
